<template>
  <div>
    <el-card style="width: 100%; max-width: 650px;">
      <div slot="header" class="title">
        <i class="el-icon-s-home"></i>
        <span>{{ ' ' + address }}</span>
      </div>
      <el-form :model="dataForm" ref="dataForm" label-width="160px" :inline="true" label-position="left" style="width: 100%;">
        <el-form-item label="业主姓名" prop="ownerName">
          <el-input v-model="dataForm.ownerName" readonly></el-input>
        </el-form-item>
        <el-form-item label="房屋号" prop="houseId">
          <el-input v-model="dataForm.houseId" readonly></el-input>
        </el-form-item>
        <el-form-item label="安全检查员姓名" prop="inspectorName">
          <el-input v-model="dataForm.inspectorName" readonly></el-input>
        </el-form-item>
        <el-form-item label="检查员联系方式" prop="inspectorPhone">
          <el-input v-model="dataForm.inspectorPhone" readonly></el-input>
        </el-form-item>
        <el-form-item label="最近一次安全检查日期" prop="lastInspectionDate">
          <el-input v-model="dataForm.lastInspectionDate" readonly></el-input>
        </el-form-item>
        <el-form-item label="最近一次安全检查结果" prop="lastInspectionResult">
          <el-input v-model="dataForm.lastInspectionResult" readonly></el-input>
        </el-form-item>
        <el-form-item label="有无消防疏散示意图" prop="diagram">
          <el-input v-model="hasDiagram" readonly></el-input>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
export default {
  mounted() {
    this.getData()
  },
  data() {
    return {
      dataForm: {
        ownerName: '',
        houseId: 0,
        floorNumber: '',
        buildingName: '',
        inspectorName: '',
        inspectorPhone: '',
        lastInspectionDate: '',
        lastInspectionResult: '',
        diagram: '',
      },
      //有无疏散图
      hasDiagram: '',
      //房屋地址
      address: '',
    }
  },

  methods: {
    getData() {
      let loginUser=JSON.parse(localStorage.getItem('user')) || {}
      this.dataForm.ownerName=loginUser.name

      this.$request({
        url: `/house/house/getBasicInfo`,
        method: 'get',
        params: {}
      }).then((res) => {
        if (res && res.code === 200) {
          this.dataForm.houseId = res.data.houseId
          this.dataForm.inspectorName = res.data.inspectorName
          this.dataForm.inspectorPhone = res.data.inspectorPhone
          this.dataForm.lastInspectionDate = res.data.lastInspectionDate
          this.dataForm.lastInspectionResult = res.data.lastInspectionResult.toFixed(2)
          this.hasDiagram = res.data.hasDiagram?'有':'无'
          this.address = res.data.address
        }else{
          this.$message.error(res.msg)
        }
      })
    }
  }

}
</script>

<style scoped>

.title {
  font-size: 20px;
  font-weight: bolder;
}

</style>
